ASP.NET Core 5 and React by Carl Rippon
Author:Carl Rippon
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2021-01-06T00:00:00+00:00
Creating a repository method to change a question
Let's create the PutQuestion method in DataRepository.cs to change a question. This is very similar to the PostQuestion method we have just implemented:
public QuestionGetSingleResponse PutQuestion(int questionId, QuestionPutRequest question)
{
using (var connection = new SqlConnection(_connectionString))
{
connection.Open();
connection.Execute(
@"EXEC dbo.Question_Put
@QuestionId = @QuestionId, @Title = @Title,
@Content = @Content",
new { QuestionId = questionId, question.Title,
question.Content }
);
return GetQuestion(questionId);
}
}
Notice that we are using the Dapper Execute method because we are simply executing a stored procedure and not returning anything.
We've created the SQL parameters from a model class called QuestionPutRequest and the questionId parameters that were passed into the method. Let's create the QuestionPutRequest class in the models folder:
public class QuestionPutRequest
{
public string Title { get; set; }
public string Content { get; set; }
}
That's another method implemented.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(20293)
Hello! Python by Anthony Briggs(19621)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(17890)
Dependency Injection in .NET by Mark Seemann(17855)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(17298)
Kotlin in Action by Dmitry Jemerov(16849)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(13111)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(11266)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(9279)
Svelte with Test-Driven Development by Daniel Irvine(8138)
Test-Driven Development with PHP 8 by Rainier Sarabia(7887)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(7707)
Web Development with Django by Ben Shaw Saurabh Badhwar(7216)
React Application Architecture for Production by Alan Alickovic(6896)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4980)
Audition by Ryu Murakami(4879)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4835)
Solidity Programming Essentials by Ritesh Modi(4558)
Build Your Own Web Framework in Elixir by Aditya Iyengar(4434)